<template>
  <div class="friend-list" :class="{'default': !hasFriend}">
    <div v-if="hasFriend">
      <FriendItem
        class="list-item" 
        v-for="friend in friendList" 
        :key="friend.userID" 
        :friend="friend" />
    </div>
    <div style="color:gray;" v-else>暂无好友</div>
  </div>
</template>
<script>
import { mapState } from 'vuex';
import FriendItem from './FriendItem.vue'

export default {
  components: {
    FriendItem
  },
  computed: {
    ...mapState({
      friendList: state => state.friend.friendList
    }),
    hasFriend() {
      return this.friendList.length > 0
    }
  }
}
</script>

<style scoped>
.list-item :hover{
  background-color: #404953;
}
.default {
  padding-top: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  overflow-y: scroll;
}
</style>